package com.bai.localshop.controller.user;

import com.bai.localshop.pojo.dto.OrderSubmitDTO;
import com.bai.localshop.pojo.dto.OrdersPaymentDTO;
import com.bai.localshop.pojo.vo.OrderSubmitVO;
import com.bai.localshop.result.Result;
import com.bai.localshop.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户端订单控制器
 */
@RestController("userOrderController")
@RequiredArgsConstructor
@RequestMapping("/api/user/orders")
public class OrderController {
    private final OrderService orderService;

    /**
     * 用户下单
     */
    @PostMapping("/submit")
    public Result<OrderSubmitVO> submit(@RequestBody OrderSubmitDTO requestParam) {
        return Result.success(orderService.submit(requestParam));
    }

    /**
     * 订单支付
     */
    @PostMapping("/payment")
    public Result<String> payment(@RequestBody OrdersPaymentDTO requestParam){
        orderService.payment(requestParam);
        return Result.success();
    }
}
